﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="/style/rightdirectory.css" rel="stylesheet" />
    <script src="/script/list-config.js"></script>
</head>
<style>
    th {
        text-align: center;
    }
    td {
        text-align: center;
    }
   
</style>
<body>
    <div class="view-page">
        <!--搜索区域-->
        <div class="view-search inline">
            <div class="form-inline">
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">电话</span>
                        <input id="query" type="text" class="form-control" data-form="Phone" placeholder="电话">
                    </div>
                </div>
                <div class="form-group col-sm-2">
                    <div class="input-group">
                        <span class="input-group-addon">账户</span>
                        <input id="query" type="text" class="form-control" data-form="Account" placeholder="账户">
                    </div>
                </div>

                <div class="form-group">
                    <button type="button" id="btn-search" class="btn btn-primary">
                        <i class="fa fa-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>
        <div class="view-eidt-btns">
            <a href="/views/supplier/user/edit.html" class="btn btn-sm">
                <i class="fa fa-plus"></i>添加
            </a>
            <a href="javascript:;" class="btn btn-sm" data-btn-eidt="/views/supplier/user/edit.html?v=">
                <i class="fa fa-edit"></i>编辑
            </a>

            <a href="javascript:;" class="btn btn-sm" onclick="pass()">
                <i class="fa fa-edit"></i>修改密码
            </a>

            <a href="javascript:;" class="btn btn-danger btn-sm" onclick="frozen(0)">
                <i class="fa fa-edit"></i>账户冻结
            </a>

            <a href="javascript:;" class="btn btn-danger btn-sm" onclick="frozen(2)">
                <i class="fa fa-edit"></i>账户解冻
            </a>
        </div>
        <div class="view-data">
            <table id="table" class="table table-bordered table-hover" data-post="">
                <thead>
                    <tr>
                        <th class="checkboxs">
                            <label class="checkbox-reset">
                                <input type="checkbox" data-checked-table="all" />
                            </label>
                        </th>
                        <th>账户</th>
                        <th>真实名称</th>
                        <th>电话</th>
                        <th>别名</th>
                        <th>编号</th>
                        <th>省</th>
                        <th>市</th>
                        <th>区县</th>
                        <th>详细地址</th>
                        <th>账户状态</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--分页条 默认选择id=list-page元素-->
            <div id="list-page" class="view-pagination-page"></div>
        </div>
    </div>   
</body>

</html>
<script type="text/html" id="tp-table">
    {{each list d}}
    <tr data-eidt="{{d.Supplier_Id}}">
        <td class="checkboxs">
            <label class="checkbox-reset">
                <input type="checkbox" value="{{d.Supplier_Id}}" data-checked-table="single" />
            </label>
        </td>
        <td>{{d.Account}}</td>
        <td>{{d.Name}}</td>
        <td>{{d.Phone}}</td>
        <td>{{d.Alias}}</td>
        <td>{{d.No}}</td>
        <td>{{d.Province}}</td>
        <td>{{d.City}}</td>
        <td>{{d.County}}</td>
        <td>{{d.Address}}</td>
        {{if d.Status==1}}
        <td>正常</td>
        {{else if d.Status==2}}
        <td>冻结</td>
        {{/if}}
        <td>{{d.CreateDate|to_date}}</td>
    </tr>
    {{/each}}
</script>

<script type="text/javascript">
    $(function() {
        function _LoadData() {
            var parm = $(".view-search").getFormData();
            $("#table").ajaxPageTable("supplier/plist", parm, function (d) {
             
                $("#table>tbody").append(template("tp-table", {
                    list: d
                }));
            })
        }
        _LoadData();//初启化
        $(".form-control").focus(function () { //搜索按钮
            $(".form-control").keydown(function (e) {
                if (e.keyCode == 13) {
                    _LoadData();
                }
            })
        })

        $("#btn-search").click(function () { //搜索按钮
            _LoadData();
        })

    })


    function pass() {
        var arr = [];
        var checkbox = $("#table").getTableChecked({ type: {} });
        if (checkbox.length <= 0 || checkbox.length>=2) {
            $.msgFall("请选择要修改的！"); return;
        }
        arr.push(parseInt(checkbox));
        window.location.href = "/views/supplier/user/pass.html?v=" + arr;
    }

    function frozen(h) {  //解冻、冻结
        var arr = [];
        var frozen = "确定要冻结嘛？";
        var url = "supplier/freeze";
        var tem = "冻结成功";
        var checkbox = $("#table").getTableChecked({ type: {} });
        if (checkbox.length <= 0) {
            $.msgFall("请选择要修改的！"); return;
        }
        $.each(checkbox, function (i, item) {
            arr.push(parseInt(item));
        });
        if (h > 0) { frozen = "确定要解冻嘛？"; tem ="解冻成功";  url = "supplier/unfreeze";}
        $.alert(frozen, function () {
           
            $.http.json(url, {
                Id: arr
            }, {
                    pass: function (data) {
                        $.msgSucceed(tem);
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000)
                    },
                    error: function (d) {
                        console.log(d);
                    }
                })
        })
    }
</script>